package br.com.itc.componentes.input
{
	import flash.events.Event;
	import flash.events.KeyboardEvent;
	
	import mx.events.FlexEvent;
	import mx.validators.Validator;
	
	public class CPF extends Mascara
	{
		
		private var validador: Validator = new Validator;
		
		public function CPF()
		{
			this.addEventListener(FlexEvent.CREATION_COMPLETE, init);
		}
		
		private function init(event: FlexEvent): void {
			this.inputMask = "999.999.999-99";
			
			this.addEventListener(KeyboardEvent.KEY_UP, validar);
			validador.source = this;
			validador.property = "minLength";
			validador.required = true;
			validador.requiredFieldError = descricaoErro;
			validar(null);
		}
		
		override public function validar(evt: Event = null): void {
			dispatchEvent(new FlexEvent(FlexEvent.VALUE_COMMIT));
			resourceManager.update();
		}
	}
}